package com.ws.entity;

import java.util.Comparator;
import java.util.Scanner;

/**
 * @author 王硕
 * @version jdk21
 * @className Game
 * @description
 * @date 2024/11/7 16:50
 */
public class Game {
    User user = new User();
    Computer computer = new Computer();
    public void initial(){
        System.out.println("************************* *************************");
        System.out.println("*                                                 *");
        System.out.println("******************++ 猜拳,开始 **********************");
        System.out.println("*                                                 *");
        System.out.println("************************* *************************");
        System.out.println("游戏规则:1.剪刀   2.石头  3.布");
    }
    public String startGame(){
        Scanner scanner = new Scanner(System.in);
        System.out.println("请选择你要对战的电脑(请输入对应编号):");
        System.out.println("1——芙蓉王  2——瑞克五代  3——2.5坤");
        int inputcomputer = scanner.nextInt();
        if (inputcomputer==1){
            computer.setName("芙蓉王");
            System.out.println("你选择了和"+computer.getName()+"对战");
            computer.setName("芙蓉王");;
        }else if (inputcomputer==2){
            computer.setName("瑞克五代");
            System.out.println("你选择了和"+computer.getName()+"对战");
            computer.setName("瑞克五代");
        }else if (inputcomputer==3){
            computer.setName("2.5坤");
            System.out.println("你选择了和"+computer.getName()+"对战");
            computer.setName("2.5坤");
        }
        return computer.getName();
    }

    public void compare(){
        int count1=0;
        int count2=0;
        String input="";
        do {
            user.show();
            if (user.getUseroutput() < 1 || user.getUseroutput() > 3) {
                System.out.println("输入无效，请输入1、2或3:");
                continue;
            }
            computer.show();
            if (user.getUseroutput() == computer.getComputeroutput()) {
                System.out.println("平局！");
            } else if (user.getUseroutput()==2&&computer.getComputeroutput()==1||
                    user.getUseroutput()==1&&computer.getComputeroutput()==3||
                    user.getUseroutput()==3&&computer.getComputeroutput()==2) {
                System.out.println("你赢了！");
                count1++;
            } else {
                System.out.println(computer.getName()+"赢了！");
                count2++;
            }
            System.out.println("继续请输入y/n");
            Scanner scanner = new Scanner(System.in);
            input= scanner.next();
        }while ("y".equals(input));
        System.out.println("你   vs  "+computer.getName());
        System.out.println("你    "+count1);
        System.out.println(computer.getName()+"  "+count2);
    }
}
